package com.cloud.wms.ui.sort.entity;

import com.annimon.stream.Stream;
import com.cloud.wms.ui.main.entity.CommodityEntity;
import com.google.gson.annotations.SerializedName;

import java.util.List;

/**
 * @Author:Chen
 * @Date: 2021-03-30 15:55
 * @Description:
 */
public class SortCommodityEntity extends CommodityEntity {

    /**
     * posID : 0
     * commodityID : 0
     * productBatchID : 0
     * stockType : 0
     * amount : 0
     * lstorderBox : [{"orderID":0,"containerID":0,amount : 0,"orderNum":"string","boxMarking":"string"}]
     */
    @SerializedName("lstorderBox")
    private List<OrderBoxBean> orderBoxBeans;
    private int needAmount;

    public int getNeedAmount() {
        return needAmount;
    }

    public void setNeedAmount(int needAmount) {
        this.needAmount = needAmount;
    }

    public List<OrderBoxBean> getOrderBoxBeans() {
        return orderBoxBeans;
    }

    public List<OrderBoxBean> getSortOrder() {
        return Stream.ofNullable(orderBoxBeans)
                .sortBy(OrderBoxBean::getBindNum)
                .toList();
    }

    public void setOrderBoxBeans(List<OrderBoxBean> orderBoxBeans) {
        this.orderBoxBeans = orderBoxBeans;
    }

    public static class OrderBoxBean {
        /**
         * orderID : 0
         * containerID : 0
         * boxMarking : string
         * <p>
         * {
         * "orderID": 687802,
         * "containerID": 39686604,
         * "containerCode": "LCK-0000031",
         * "boxMarking": null,
         * "needAmount": 6,
         * "bindNum": 0
         * }
         */


        private String orderCode;
        private long orderID;
        private String containerCode;
        private long containerID;
        private String bindNum;
        private boolean state;
        private int needAmount;

        public int getNeedAmount() {
            return needAmount;
        }

        public void setNeedAmount(int needAmount) {
            this.needAmount = needAmount;
        }

        public String getOrderCode() {
            return orderCode == null ? "" : orderCode;
        }

        public void setOrderCode(String orderCode) {
            this.orderCode = orderCode;
        }

        public String getBindNum() {
            return bindNum == null ? "" : bindNum;
        }

        public void setBindNum(String bindNum) {
            this.bindNum = bindNum;
        }

        public boolean isState() {
            return state;
        }

        public void setState(boolean state) {
            this.state = state;
        }

        public long getOrderID() {
            return orderID;
        }

        public void setOrderID(long orderID) {
            this.orderID = orderID;
        }

        public long getContainerID() {
            return containerID;
        }

        public void setContainerID(long containerID) {
            this.containerID = containerID;
        }

        public String getContainerCode() {
            return containerCode;
        }

        public void setContainerCode(String containerCode) {
            this.containerCode = containerCode;
        }
    }
}
